_init: function() {
this.isLoading = false;
this.isDummy = true;
+ this.hasCalendars = false;
},
destroy: function() {
<arg type="b" direction="in" />
<arg type="a(sssbxxa{sv})" direction="out" />
</method>
+<property name="HasCalendars" type="b" access="read" />
<signal name="Changed" />
</interface>;
g_interface_name: CalendarServerInfo.name,
g_interface_info: CalendarServerInfo,
g_name: 'org.gnome.Shell.CalendarServer',
- g_object_path: '/org/gnome/Shell/CalendarServer',
- g_flags: Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES });
+ g_object_path: '/org/gnome/Shell/CalendarServer' });
}
function _datesEqual(a, b) {
this._onNameVanished();
}));
+ this._dbusProxy.connect('g-properties-changed', Lang.bind(this, function() {
+ this.emit('notify::has-calendars');
+ }));
+
this._initialized = true;
+ this.emit('notify::has-calendars');
this._onNameAppeared();
}));
},
this._dbusProxy.run_dispose();
},
+ get hasCalendars() {
+ if (this._initialized)
+ return this._dbusProxy.HasCalendars;
+ else
+ return false;
+ },
+
_resetCache: function() {
this._events = [];
this._lastRequestBegin = null;
this._openClocksItem.actor.visible = app !== null;
},
- _setEventsVisibility: function(visible) {
+ _updateEventsVisibility: function() {
+ let visible = this._eventSource.hasCalendars;
this._openCalendarItem.actor.visible = visible;
+ this._openClocksItem.actor.visible = visible;
this._separator.visible = visible;
if (visible) {
let alignment = 0.25;
this._eventList.setEventSource(eventSource);
this._eventSource = eventSource;
+ this._eventSource.connect('notify::has-calendars', Lang.bind(this, function() {
+ this._updateEventsVisibility();
+ }));
},
_sessionUpdated: function() {
eventSource = new Calendar.EmptyEventSource();
}
this._setEventSource(eventSource);
- this._setEventsVisibility(showEvents);
+ this._updateEventsVisibility();
// This needs to be handled manually, as the code to
// autohide separators doesn't work across the vbox
}
}
-GList *
-calendar_sources_get_appointment_clients (CalendarSources *sources)
+static void
+ensure_appointment_sources (CalendarSources *sources)
{
- GList *list, *link;
-
- g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
-
if (!sources->priv->appointment_sources.loaded)
{
calendar_sources_load_esource_list (sources->priv->registry,
&sources->priv->appointment_sources);
sources->priv->appointment_sources.loaded = TRUE;
}
+}
+
+GList *
+calendar_sources_get_appointment_clients (CalendarSources *sources)
+{
+ GList *list, *link;
+
+ g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
+
+ ensure_appointment_sources (sources);
list = g_hash_table_get_values (sources->priv->appointment_sources.clients);
return list;
}
-GList *
-calendar_sources_get_task_clients (CalendarSources *sources)
+static void
+ensure_task_sources (CalendarSources *sources)
{
- GList *list, *link;
-
- g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
-
if (!sources->priv->task_sources.loaded)
{
calendar_sources_load_esource_list (sources->priv->registry,
&sources->priv->task_sources);
sources->priv->task_sources.loaded = TRUE;
}
+}
+
+GList *
+calendar_sources_get_task_clients (CalendarSources *sources)
+{
+ GList *list, *link;
+
+ g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), NULL);
+
+ ensure_task_sources (sources);
list = g_hash_table_get_values (sources->priv->task_sources.clients);
return list;
}
+
+gboolean
+calendar_sources_has_sources (CalendarSources *sources)
+{
+ g_return_val_if_fail (CALENDAR_IS_SOURCES (sources), FALSE);
+
+ ensure_appointment_sources (sources);
+ ensure_task_sources (sources);
+
+ return g_hash_table_size (sources->priv->appointment_sources.clients) > 0 ||
+ g_hash_table_size (sources->priv->task_sources.clients) > 0;
+}
GList *calendar_sources_get_appointment_clients (CalendarSources *sources);
GList *calendar_sources_get_task_clients (CalendarSources *sources);
+gboolean calendar_sources_has_sources (CalendarSources *sources);
+
G_END_DECLS
#endif /* __CALENDAR_SOURCES_H__ */
" <signal name='Changed'/>"
" <property name='Since' type='x' access='read'/>"
" <property name='Until' type='x' access='read'/>"
+ " <property name='HasCalendars' type='b' access='read'/>"
" </interface>"
"</node>";
static GDBusNodeInfo *introspection_data = NULL;
app->cache_invalid = FALSE;
}
+static gboolean
+app_has_calendars (App *app)
+{
+ return calendar_sources_has_sources (app->sources);
+}
+
static void
on_appointment_sources_changed (CalendarSources *sources,
gpointer user_data)
print_debug ("Sources changed\n");
app_load_events (app);
+
+ /* Notify the HasCalendars property */
+ {
+ GVariantBuilder dict_builder;
+
+ g_variant_builder_init (&dict_builder, G_VARIANT_TYPE ("a{sv}"));
+ g_variant_builder_add (&dict_builder, "{sv}", "HasCalendars",
+ g_variant_new_boolean (app_has_calendars (app)));
+
+ g_dbus_connection_emit_signal (g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL),
+ NULL,
+ "/org/gnome/Shell/CalendarServer",
+ "org.freedesktop.DBus.Properties",
+ "PropertiesChanged",
+ g_variant_new ("(sa{sv}as)",
+ "org.gnome.Shell.CalendarServer",
+ &dict_builder,
+ NULL),
+ NULL);
+ }
}
static App *
{
ret = g_variant_new_int64 (app->until);
}
+ else if (g_strcmp0 (property_name, "HasCalendars") == 0)
+ {
+ ret = g_variant_new_boolean (app_has_calendars (app));
+ }
else
{
g_assert_not_reached ();